#include "vector.hpp"

Vector::Vector(void) : x(0.0), y(0.0) , z(0.0) 
{ }

Vector::Vector(const double _x, const double _y,const double _z) : x(_x), y(_y), z(_z) 
{ }

Vector::~Vector(void) { }

const double Vector::dot_product(const Vector& objeto) const {
	return x*objeto.x+ y*objeto.y+ z*objeto.z;
}

Vector Vector::cross_product(const Vector& objeto) const {
	
	return Vector(y*objeto.z - z*objeto.y, z*objeto.x - x*objeto.z,x*objeto.y - y*objeto.x);
}

Vector Vector::scalar_product(const double valor) const {
	return Vector(x*valor,y*valor,z*valor);
}

Vector Vector::normalize(void) const{
	Vector normalizado(*this);
	double mod = normalizado.dot_product(normalizado);
	if(mod != 0.0) { 
		normalizado = normalizado.scalar_product(1.0/sqrt(mod));
		
	}
	return normalizado;
}

Vector Vector::sub_vect(const Vector& _vector) const {
	return Vector(this->x-_vector.x,
			this->y-_vector.y,
			this->z-_vector.z);
}

const double Vector::lenght(void) const {
	return sqrt(this->dot_product(*this));
}

void Vector::set(const double _x,const double _y,const double _z) { 
	x = _x;
	y = _y;
	z = _z;
}

const double Vector::operator*(const Vector& _vector) const {
    return this->dot_product(_vector);
}

const Vector Vector::operator*(const double _value) const {
    return this->scalar_product(_value);
}

const Vector Vector::operator+(const Vector& _vector) const {
    return Vector(x + _vector.x,y + _vector.y,z + _vector.z);
}
